<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>async与await结合</title>
</head>
<body>
    <button id="btn">点击获取段子</button>
    <script>
        function sendAJAX(url){
            return new Promise((resolve,reject)=>{
                resolve('OK');
            })
        }

        let btn = document.querySelector('#btn');
        btn.addEventListener('click',async function(){
            let duanzi = await sendAJAX('https://api.apiopen.top/getJoke');
            console.log(duanzi);
        })
    </script>
    
</body>
</html>